package com.neutech.controller;

import com.neutech.service.ConfirmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class ConfirmController {
    @Autowired
    private ConfirmService confirmService;
    @RequestMapping("/query/confirm")
    @ResponseBody
    public List<Map<String ,Object>> queryConfirmByName(@RequestParam Map map)
    {
        List<Map<String,Object>> list = confirmService.queryConfirmByName(map.get("name").toString());
        System.out.println(list);
        return confirmService.queryConfirmByName(map.get("name").toString());

    }
    @RequestMapping("/addconfirm")
    @ResponseBody
    public void addConfirm(@RequestParam Map map){
        for(Object key:map.keySet()){
            String value = (String) map.get(key);
            System.out.println(key + ":" + value);
        }
        confirmService.addConfirm(map);
    }
    @ResponseBody
    @RequestMapping("/confirm")
    public List<Map<String, Object>> getconfirm(@RequestParam Map map)
    {

        return confirmService.queryConfirmList();

    }
    @ResponseBody
    @RequestMapping("/idconfirm")
    public List<Map<String, Object>> getidconfirm(@RequestParam Map map)
    {

        return confirmService.queryConfirmByIdnumber(Integer.parseInt(map.get("idnumber").toString()));

    }

//    @PostMapping("/login")
//    @ResponseBody
//    public String isForm(@RequestParam Map map){
//        System.out.println(map.get("name"));
//        return "ok";
//    }
}
